//
//  OrderInformationViewController.m
//  groupProject
//
//  Created by mac on 15/12/29.
//  Copyright © 2015年 mac. All rights reserved.
//

#import "OrderInformationViewController.h"
#import "Config.h"
@interface OrderInformationViewController ()

@end

@implementation OrderInformationViewController{
    NSMutableArray * array1;
    NSMutableArray * array2;
    NSMutableArray * array3;
    NSMutableArray * array4;
    NSMutableArray * array5;
    NSMutableArray * array6;
    
}
@synthesize Ordersegment,OrdertableView;
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self addHeardBtn];
    array1 = [NSMutableArray array];
    array2 = [NSMutableArray array];
    array3 = [NSMutableArray array];
    array4 = [NSMutableArray array];
    array5 = [NSMutableArray array];
    array6 = [NSMutableArray array];


    
}
-(void)addHeardBtn{
    NSArray * segmentArray = [NSArray arrayWithObjects:@"全部",@"待付款", @"待发货",@"待收货",@"待评价", @"退换货", nil];
    Ordersegment = [[UISegmentedControl alloc]initWithItems:segmentArray];
    Ordersegment.frame = CGRectMake(5, 64, SCREEN_WIDTH-5, 30);
    Ordersegment.selectedSegmentIndex = _segmentIndex;
    Ordersegment.tintColor= [UIColor redColor];
    NSDictionary* selectedTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:17],
                                             NSForegroundColorAttributeName: [UIColor whiteColor]};
    [Ordersegment setTitleTextAttributes:selectedTextAttributes forState:UIControlStateSelected];//设置文字属性
    NSDictionary* unselectedTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:14],
                                               NSForegroundColorAttributeName: [UIColor redColor]};
    [Ordersegment setTitleTextAttributes:unselectedTextAttributes forState:UIControlStateNormal];
    
    [Ordersegment addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:Ordersegment];
    
}
-(void)segmentAction:(UISegmentedControl *)Seg
{
    NSInteger index = Seg.selectedSegmentIndex;
   // NSLog(@"Index %li",(long)index);
    switch (index) {
        case 0:
            [OrdertableView reloadData];
            break;
        case 1:
            [OrdertableView reloadData];
            break;
        case 2:
            [OrdertableView reloadData];
            break;
        case 3:
            [OrdertableView reloadData];
            break;
        case 4:
            [OrdertableView reloadData];
            break;
        case 5:
            [OrdertableView reloadData];
            break;
            
        default:
            break;
    }

}
-(void)panduan{
    if (array1.count == 0||array1 == nil ||array2.count == 0||array2 == nil||array3.count == 0||array3 == nil||array4.count == 0||array4 == nil||array5.count == 0||array5 == nil||array6.count == 0||array6 == nil) {
        self.view = [self nilView];
    }else{
        OrdertableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCROLL_HEIGHT)];
        [self.view addSubview:OrdertableView];
        
    }
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (Ordersegment.selectedSegmentIndex == 0) {
        return array1.count;
    }else if(Ordersegment.selectedSegmentIndex == 1)
    {
        return array2.count;
    }else if(Ordersegment.selectedSegmentIndex == 2)
    {
        return array2.count;
    }else if(Ordersegment.selectedSegmentIndex == 3)
    {
        return array2.count;
    }else if(Ordersegment.selectedSegmentIndex == 4)
    {
        return array2.count;
    }else if(Ordersegment.selectedSegmentIndex == 5)
    {
        return array2.count;
    }
    return 0;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSMutableArray * tmpArray = [[NSMutableArray alloc]init];
    if (Ordersegment.selectedSegmentIndex == 0) {
        tmpArray = array1;
    }else if(Ordersegment.selectedSegmentIndex == 1){
        tmpArray = array2;
    }else if(Ordersegment.selectedSegmentIndex == 2){
        tmpArray = array2;
    }else if(Ordersegment.selectedSegmentIndex == 3){
        tmpArray = array2;
    }else if(Ordersegment.selectedSegmentIndex == 4){
        tmpArray = array2;
    }else if(Ordersegment.selectedSegmentIndex == 5){
        tmpArray = array2;
    }

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = [tmpArray objectAtIndex:indexPath.row];
    return cell;
}
-(UIView *)nilView{
    UIView  * view = [[UIView alloc]initWithFrame:self.view.frame];
    UILabel * tmplabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 80, 80, 80)];
    tmplabel.backgroundColor = [UIColor redColor];
    [view addSubview:tmplabel];
    return view;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
